from typing import Optional, List
from pydantic import BaseModel, HttpUrl, Field


class ParseVideoRequest(BaseModel):
    """视频解析请求模型"""
    url: str = Field(..., description="视频链接")
    platform: Optional[str] = Field("auto", description="平台类型 (douyin, tiktok, bilibili, auto)")


class BatchParseRequest(BaseModel):
    """批量视频解析请求模型"""
    urls: List[str] = Field(..., description="视频链接列表")
    platform: Optional[str] = Field("auto", description="平台类型")


class VideoInfo(BaseModel):
    """视频信息响应模型"""
    id: str = Field(..., description="视频ID")
    title: str = Field(..., description="视频标题")
    author: str = Field(..., description="作者名称") 
    author_id: Optional[str] = Field(None, description="作者ID")
    platform: str = Field(..., description="平台类型")
    download_url: str = Field(..., description="下载链接")
    original_url: Optional[str] = Field(None, description="原始视频链接")
    cover_url: str = Field(..., description="封面链接")
    duration: Optional[int] = Field(None, description="视频时长(秒)")
    view_count: Optional[int] = Field(None, description="播放次数")
    like_count: Optional[int] = Field(None, description="点赞数")
    comment_count: Optional[int] = Field(None, description="评论数")
    share_count: Optional[int] = Field(None, description="分享数")
    create_time: Optional[str] = Field(None, description="发布时间")
    description: Optional[str] = Field(None, description="视频描述")


class ApiResponse(BaseModel):
    """通用API响应模型"""
    code: int = Field(200, description="响应码")
    message: str = Field("success", description="响应消息")
    data: Optional[dict] = Field(None, description="响应数据")


class ErrorResponse(BaseModel):
    """错误响应模型"""
    code: int = Field(..., description="错误码")
    message: str = Field(..., description="错误消息")
    detail: Optional[str] = Field(None, description="错误详情")


class HealthResponse(BaseModel):
    """健康检查响应模型"""
    status: str = Field("ok", description="服务状态")
    service: str = Field("python-crawler", description="服务名称")
    version: str = Field("1.0.0", description="服务版本")
    timestamp: str = Field(..., description="检查时间")


class PlatformInfo(BaseModel):
    """平台信息模型"""
    name: str = Field(..., description="平台名称")
    code: str = Field(..., description="平台代码")
    enabled: bool = Field(True, description="是否启用")
    description: str = Field(..., description="平台描述")